package com.lelefly.base.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lelefly.base.daoimp.BaseDao;
import com.lelefly.base.model.LeleflyUserVo;
import com.lelefly.base.model.Result;
import com.lelefly.base.po.LfFeedback;
import com.lelefly.constant.Constant;

@Controller
@RequestMapping("/fd")
public class FeedbackController extends BaseController{
	
	@Resource
	public BaseDao baseDao;
	
	@SuppressWarnings("rawtypes")
	@RequestMapping(value="/addfeedback",produces="application/json;charset=utf-8")
	@ResponseBody
	public Result addfeedback(LfFeedback feedback){
		Result<LfFeedback> result=new Result<>();
		try {
			baseDao.saveObject(feedback);
			result.setState(Constant.HTTP_STATUS_OK);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			result.setState(Constant.HTTP_STATUS_FAIL);
//			result.setAllCount(e.getLocalizedMessage());
			getLogger().info("----->>"+e.getLocalizedMessage());
		}
		return result;
	}

	
	@SuppressWarnings("rawtypes")
	@RequestMapping(value="/getfeedback",produces="application/json;charset=utf-8")
	@ResponseBody
	public Result getfeedback(){
		Result<LfFeedback> result=new Result<>();
		try {
			String hql = "from LfFeedback as model";
			List<LfFeedback> feedbacks = baseDao.queryObjetReList(hql);
			result.setResultList(feedbacks);
			result.setState(Constant.HTTP_STATUS_OK);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			result.setState(Constant.HTTP_STATUS_FAIL);
//			result.setAllCount(e.getLocalizedMessage());
			getLogger().info("----->>"+e.getLocalizedMessage());
		}
		return result;
	}
}
